package com.yn.pet.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yn.pet.dao.AppUserDao;
import com.yn.pet.entity.AppUser;
import com.yn.pet.service.AppUserService;
import io.jsonwebtoken.lang.Assert;
import org.springframework.stereotype.Service;

/**
 * APP用户表(AppUser)表服务实现类
 *
 * @author makejava
 * @since 2025-07-09 16:26:55
 */
@Service("appUserService")
public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUser> implements AppUserService {

    @Override
    public AppUser getByPhone(String phone) {
        Assert.hasText(phone, "手机号码不能为空");
        return this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, phone)).stream().findAny().orElse(null);
    }

    @Override
    public AppUser getMiniOpenid(String miniOpenid) {
        Assert.hasText(miniOpenid, "miniOpenid不能为空");
        return this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getMiniOpenid, miniOpenid)).stream().findAny().orElse(null);
    }
}

